<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <h:form>
            <p:layout>
                <p:layoutUnit position="north" size="230" resizable="false" closable="false" collapsible="true">
                    <h:graphicImage url="/banner.jpg" width="700" height="200"/>
                    <h:outputText value = " Logado como cliente: #{managedBeanClientes.cliente.nome} " 
                                  rendered="#{managedBeanClientes.login}"/> 
                    <h:commandButton value = "Carrinho: #{managedBeanVenda.listaCarrinho.size()} " action="venda" 
                                     rendered="#{managedBeanClientes.login}"/>
                    <h:commandButton value = "Minha conta" action="dadospessoais-cliente" 
                                     rendered="#{managedBeanClientes.login}"/>
                    <h:commandButton value = "Sair" action="#{managedBeanClientes.logout()}" 
                                     rendered="#{managedBeanClientes.login}"/>    

                </p:layoutUnit>

                <p:layoutUnit position="west" size="259" collapsible="true">
                    <p:menu>
                        <p:submenu label="Login" rendered="#{!managedBeanClientes.login and !managedBeanEmpresa.login}">
                            <p:menuitem value="Cliente" outcome="login-cliente" />
                            <p:menuitem value="Empresa" outcome="login-empresa"/>
                        </p:submenu>
                        <p:submenu label="Cadastre-se" rendered="#{!managedBeanClientes.login and !managedBeanEmpresa.login}">
                            <p:menuitem value="Cliente" outcome="cadastro-cliente" />
                            <p:menuitem value="Empresa" outcome="cadastro-empresa"/>
                        </p:submenu>
                        <p:submenu label="Minha Empresa" rendered="#{managedBeanEmpresa.login}">
                            <p:menuitem value="Cadastrar Ônibus" outcome="cadastro-onibus"/>
                            <p:menuitem value="Cadastrar Viagem" outcome="cadastro-viagem" />
                        </p:submenu>
                        <p:submenu label="Menu">
                            <p:menuitem value="Inicio" outcome="index"/>
                            <p:menuitem value="Quem Somos" outcome="quemsomos" />
                            <p:menuitem value="Empresas Filiadas" outcome="lista-empresa"/>
                            <p:menuitem value="Compra de Passagens" outcome="consulta-onibus" rendered="#{!managedBeanEmpresa.login}"/>
                            <p:menuitem value="Minhas Compras" outcome="index" rendered="#{managedBeanClientes.login}"/>
                        </p:submenu>
                    </p:menu>
                </p:layoutUnit>

                <p:layoutUnit position = "center">
                    <c:if  test="#{managedBeanClientes.login}">
                        <p:panel header ="Atualizar senha">
                            <p:panelGrid columns="2">
                                <h:outputText value= "Digite uma senha: "/>
                                <p:password value= "#{managedBeanClientes.cliente.senha}" required="true" requiredMessage="A senha é obrigatória" validatorMessage="A senha deve ter pelo menos 4 dígitos" 
                                            feedback="true" weakLabel="Fraca" goodLabel="Boa" strongLabel="Forte" promptLabel="Digite a senha" id="senha1" match="senha2">
                                    <f:validateLength minimum="4"/>
                                </p:password>
                                <h:outputText value= "Digite novamente a senha: "/>
                                <p:password value= "#{managedBeanClientes.cliente.senha}" required="true" requiredMessage="A senha é obrigatória" validatorMessage="As senhas não conferem" 
                                            id="senha2">
                                    <f:validateLength minimum="4"/>
                                </p:password>    
                            </p:panelGrid>
                            <p><h:commandButton value="Atualizar senha" action="#{managedBeanClientes.senhaatualizadaCliente()}"/></p>
                            <p:messages showDetail ="true"/>
                        </p:panel>
                    </c:if>
                </p:layoutUnit>
            </p:layout>
        </h:form>

    </h:body>
</html>

